<template>
  <div>
    <headNav title="" ></headNav>
    <div class="flexEdge headCss" @click="editClick('编辑头像')" >
      <span>头像：</span>
      <div class="flexAlign" >
        <img v-if="!identityData.portraitImgUrl" src="@/assets/img/default_heads.png" mode="" >
        <img v-else :src="identityData.portraitImgUrl" mode="" >
        <img src="@/assets/img/my/arrow.png" mode="" style="width: 0.13rem; height: 0.2rem;"  >
      </div>
    </div>

    <div class="flexEdge headCss" @click="editClick('编辑称呼')" >
      <span>称呼：</span>
      <div class="flexAlign" style="width: 5rem; justify-content: flex-end;" >
        <span style="margin-right: 0.2rem;" >{{identityData.name}}</span>
        <img src="@/assets/img/my/arrow.png" mode="" style="width: 0.13rem; height: 0.2rem;"  >
      </div>
    </div>

    <div class="flexEdge headCss" @click="editClick('修改密码')" >
      <span>修改密码：</span>
      <div class="flexAlign" >
        <img src="@/assets/img/my/arrow.png" mode="" style="width: 0.13rem; height: 0.2rem;"  >
      </div>
    </div>

    <div class="flexCenter signOutCss" >
      <button type="default" @click="signOutClick" >退出登录</button>
    </div>
  </div>
</template>

<script>
import headNav from '@/components/headNav/headNav.vue'
import { mapActions, mapState, mapGetters, mapMutations } from 'vuex'
export default {
  components: {
    headNav,
  },
  computed: {
    ...mapState({
      studentId: state => state.user.studentId,
      roleCode: state => state.user.roleCode
    })
  },
  data () {
    return {
      identityData: ''
    }
  },
  methods: {
    editClick (e) {
      localStorage.editClass = e
      this.$router.push('modifySettings')
    },
    // 退出登录按钮触发事件
    signOutClick () {
      this.$vux.confirm.show({
          title: '提示',
          content: '是否退出登录？',
          onConfirm : () => {
            this.$store.dispatch('setting/loginOut')
          },
          onCancel () {
          }
      })

    }
  },
  mounted() {
    this.identityData = JSON.parse(localStorage.identityData)
  }
}
</script>

<style lang="less" scoped >
.signOutCss {
  width: 100%;
  margin-top: 1rem;
  button {
    color: #FFF;
    background: #128fef;
    font-size: 0.3rem;
    width: 4rem;
    height: 0.8rem;
    border-radius: 0.8rem;
    border: 0;
  }
}

.headCss {
  width: 6.2rem;
  height: 1.3rem;
  margin-left: 0.5rem;
  font-size: 0.3rem;
  border-bottom: 1px solid #d4d4d4;
  img {
    width: 0.9rem;
    height: 0.9rem;
    margin-right: 0.3rem;
    border-radius: 2.5rem;
  }
}

.flexCenter {
  display: flex;
  align-items: center;
  justify-content: center;
}

.flexHeight {
  display: flex;
  flex-direction: column;
}

.flexAlign {
  display: flex;
  align-items: center;
}

.flexEdge {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
</style>
